<form novalidate name="vm.userForm" ng-submit="vm.userForm.$valid && vm.save()">
    <div class="modal-header clearfix">
        <h4><i class="fa fa-user margin-right-5"></i><span ng-if="vm.edit">编辑用户</span><span ng-if="!vm.edit">新增用户</span> </h4>
    </div>
    <div class="modal-body clearfix">
        <div class="form-group" ng-class="{'has-error': (vm.userForm.userCode.$touched || vm.userForm.$submitted ) && (vm.userForm.userCode.$error.required || vm.userForm.userCode.$error.pattern) || vm.userForm.userCode.$error.duplicate || vm.userForm.userCode.$error.network}">
            <label for="userCode"><i ng-show="vm.userCodeChecking" class="fa-fw fa fa-refresh fa-spin"></i>用户编码: </label>
            <input type="text" class="form-control col-sm-4" id="userCode" ng-model="vm.params.userCode" placeholder="用户编码" required name="userCode" ng-pattern="/^[a-z\d]+$/" ng-blur="vm.checkUserCode()">
            <div class="text-danger" ng-show="(vm.userForm.userCode.$touched || vm.userForm.$submitted ) && (vm.userForm.userCode.$error.required || vm.userForm.userCode.$error.pattern) || vm.userForm.userCode.$error.duplicate || vm.userForm.userCode.$error.network">

                {{ ((vm.userForm.userCode.$error.required || vm.userForm.userCode.$error.pattern) && '请输入有效的用户编码 ( 只能是小写、数字 )') ||
                    (vm.userForm.userCode.$error.network && '检查用户编码请求异常') ||
                    (vm.userForm.userCode.$error.duplicate && '该用户编码已存在') || ''}}
            </div>
        </div>
        <div class="form-group" ng-class="{'has-error': (vm.userForm.userName.$touched || vm.userForm.$submitted ) && (vm.userForm.userName.$error.required)}">
            <label for="userName">用户名称: </label>
            <input type="text" class="form-control" id="userName" ng-model="vm.params.userName" placeholder="用户名称" required name="userName">
            <div class="text-danger" ng-show="(vm.userForm.userName.$touched || vm.userForm.$submitted ) && (vm.userForm.userName.$error.required )">
                请输入用户名称
            </div>
        </div>
        <div class="form-group" ng-class="{'has-error': (vm.userForm.password.$touched || vm.userForm.$submitted ) && (vm.userForm.password.$error.required||vm.userForm.password.$error.pattern)}">
            <label for="password">用户密码: </label>
            <input type="password" class="form-control" id="password" ng-model="vm.params.password" placeholder="至少8位，且同时包含大写、小写、数字" required name="password" ng-pattern="/(?![0-9A-Z]+$)(?![0-9a-z]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,}/">
            <div class="text-danger" ng-show="(vm.userForm.password.$touched || vm.userForm.$submitted ) && (vm.userForm.password.$error.required||vm.userForm.password.$error.pattern )">
                至少8位，且同时包含大写、小写、数字
            </div>
        </div>
        <div class="form-group" ng-class="{'has-error': (vm.userForm.password2.$touched || vm.userForm.$submitted ) && (vm.userForm.password2.$error.required) || (vm.userForm.password2.$viewValue != vm.userForm.password.$viewValue)}">
            <label for="password2">确认密码: </label>
            <input type="password" class="form-control" id="password2" ng-model="vm.params.password2" placeholder="请再次输入用户密码" required name="password2">
            <div class="text-danger" ng-show="(vm.userForm.password2.$touched || vm.userForm.$submitted ) || (vm.userForm.password2.$viewValue != vm.userForm.password.$viewValue)">
                {{(vm.userForm.password2.$error.required && '请再次输入用户密码') ||
                    ((vm.userForm.password2.$viewValue != vm.userForm.password.$viewValue) && '两次输入的密码不一致') || ''}}
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-default btn-sm" type="button" ng-click="vm.cancel()">取消</button>
        <button type="submit" class="btn btn-primary btn-sm">确定</button>
    </div>
</form>

